import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { LogisticsInfoVO, LogisticsInfoForm, LogisticsInfoQuery } from '@/api/logistics/channel/types';

/**
 * 查询物流渠道列表
 * @param query
 * @returns {*}
 */

export const pageLogisticsInfo = (query?: LogisticsInfoQuery): AxiosPromise<LogisticsInfoVO[]> => {
  return request({
    url: '/oa/logisticsInfo/page',
    method: 'get',
    params: query
  });
};

/**
 * 查询物流渠道详细
 * @param logisticsInfoId
 */
export const getLogisticsInfo = (logisticsInfoId: string | number): AxiosPromise<LogisticsInfoVO> => {
  return request({
    url: '/oa/logisticsInfo/' + logisticsInfoId,
    method: 'get'
  });
};

/**
 * 新增物流渠道
 * @param data
 */
export const addLogisticsInfo = (data: LogisticsInfoForm) => {
  return request({
    url: '/oa/logisticsInfo/add',
    method: 'post',
    data: data
  });
};

/**
 * 修改物流渠道
 * @param data
 */
export const updateLogisticsInfo = (data: LogisticsInfoForm) => {
  return request({
    url: '/oa/logisticsInfo/edit',
    method: 'put',
    data: data
  });
};

/**
 * 删除物流渠道
 * @param logisticsInfoId
 */
export const delLogisticsInfo = (logisticsInfoId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/logisticsInfo/' + logisticsInfoId,
    method: 'delete'
  });
};
